package com.springbootblog.controller.fontend.thread.async;

import java.util.ArrayList;
import java.util.List;

public class TestAsyncThree
{
    public static void main(String[] args)
    {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 100000; i++)
        {
            new Thread(new Runnable()
            {
                @Override
                public void run()
                {
                    synchronized (list)
                    {
                        list.add(Thread.currentThread().getName());
                    }
                }
            }).start();
        }
        System.out.println(list.size());
    }
}

